package com.lanlian.cayman.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.Html;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.lanlian.cayman.R;
import com.lanlian.utillib.DisplayUtil;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/12/12 11:39
 *     desc   : todo
 *     version: 1.0
 * </pre>
 */
public class RiskInvestigationDialog extends Dialog {

    private TextView mTvTips;
    private TextView mTvWrite;
    private TextView mTvClose;

    private Context mContext;
    private OnClickListener mOnClickListener;

    public interface OnClickListener {
        void onWriteClick();

        void onCloseClick();
    }

    public RiskInvestigationDialog(@NonNull Context context, OnClickListener onClickListener) {
        super(context, R.style.customDialog);
        this.mContext = context;
        this.mOnClickListener = onClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_risk_investigation);
        initView();
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = (int) (DisplayUtil.getScreenWidth(mContext) * 0.8);
        window.setAttributes(lp);

        String str = "为了给您提供更好的投资服务，请您尽快填写<font color='#4385F3'>投资风险调研书</font>。";
        mTvTips.setText(Html.fromHtml(str));
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        mTvWrite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnClickListener.onWriteClick();
                dismiss();
            }
        });
        mTvClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnClickListener.onCloseClick();
                dismiss();
            }
        });
    }

    private void initView() {
        mTvTips = findViewById(R.id.tv_tips);
        mTvWrite = findViewById(R.id.tv_write);
        mTvClose = findViewById(R.id.tv_close);
    }

}
